﻿	      <?php include("conn.php");
	      include("func/request.php");
             mysql_query('SET NAMES UTF8'); 

	  

class MyPrizeBean
{
	public $userid;
	public $result;
	public $token;
	function __construct($userid,$token,$result)
	{
		$this->userid      = $userid;
		$this->token      = $token;
		$this->result      = $result;
		
	}
}

   $phone=$_REQUEST[tel];
   $password=$_REQUEST[pass];
 
	$rert30=mysql_query("select * from user where  phone ='".$phone."' and password='".$password."'");
	
	$prize = array();
	
	$rowf=mysql_fetch_array($rert30);
	$url = "http://www.ewangpf.com/api/rongcloud/API/haha.php?uid=uid-".$rowf[userid]."&uname=".$rowf[niname]."&headimg=".$rowf[images];
	$url_ret = file_get_contents($url);
	$tokenObj = json_decode($url_ret);
	$token = $tokenObj->token;

	mysql_query('update user set pw_token="'.$token.'"'."  where  userid=".$rowf['userid']);
	if($rowf!=false){
	     $false=100;
	 }else{
	     $false=200;
	 }
	//重新检索该条记录
    $rert30=mysql_query("select * from user  where  userid=".$rowf['userid']);
    $rowf=mysql_fetch_array($rert30);

    $prize[] = new MyPrizeBean($rowf['userid'],$rowf['pw_token'],$false);

echo json_encode($prize);
?>